clear all
set more off
set maxvar 32000
set matsize 11000
*************************************************************************************************
*set scheme aspen, perm
grstyle init
grstyle set plain, horizontal grid

use "$folder/data/data_ready.dta", clear
cd "$folder/output/tables"
local x=18

xtset state year, yearly delta(2)

label variable growth_gsp "Growth GSP"
label variable log_real1gsppc "Log Real Income per capita"
label variable growth_pc "Growth Real Income per capita"
label variable lestab_D "Growth Number Estabilishments"
label variable lprofits_mill_D "Growth State Profits, Millions"
label variable lcbp_emp_D "Growth Employment"

label variable log_provisions_18 "Legislative Detail"
label variable log_cond_list_prov_18 "Contingent Provisions" 
label variable log_non_cond_list_prov_18 "Non-Contingent Provisions" 
label variable shock_prov18 "Shock to Legislative Detail"
label variable shock_cond_list_prov18 "Shock to Contingencies"
label variable shock_non_cond_list_prov18 "Shock to Non-Contingencies"

label variable gsp_initial "Initial Gross State Product"
label variable growth_initial "Initial GSP Growth"
label variable gsp_pc_initial "Initial GSP per capita"
label variable lestab_D "Growth Number Establishments"
label variable lprofits_mill_D "Growth State Profits, Millions"
label variable lcbp_emp_D "Growth Employment"

*******************
* UNCERTAINTY
*******************
xtile state_news_uncertain3 = state_news_uncertain, n(3)
******Table Uncertainty ******
*Low
* 1 // year FE, state FE
ivreghdfe growth_pc (log_provisions_`x' = shock_prov`x') if state_news_uncertain3 == 1, absorb(state year) cl(state)
outreg2 using Table_7_unc, excel replace label  ctitle(Low Unc - Prov)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 2 // year FE, state FE
ivreghdfe growth_pc (logX_diffcond_list_prov_`x' = shock_cond_list_prov`x' shock_non_cond_list_prov`x') if state_news_uncertain3 == 1, absorb(state year) cl(state)
outreg2 using Table_7_unc, excel append label  ctitle(Low Unc - Diff)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


*Med
* 3 // year FE, state FE
ivreghdfe growth_pc (log_provisions_`x' = shock_prov`x') if state_news_uncertain3 == 2, absorb(state year) cl(state)
outreg2 using Table_7_unc, excel append label  ctitle(Med Unc - Prov)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 4 // year FE, state FE
ivreghdfe growth_pc (logX_diffcond_list_prov_`x' = shock_cond_list_prov`x' shock_non_cond_list_prov`x') if state_news_uncertain3 == 2, absorb(state year) cl(state)
outreg2 using Table_7_unc, excel append label  ctitle(Med Unc - Diff)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

*High
* 5 // year FE, state FE
ivreghdfe growth_pc (log_provisions_`x' = shock_prov`x') if state_news_uncertain3 == 3, absorb(state year) cl(state)
outreg2 using Table_7_unc, excel append label  ctitle(High Unc - Prov)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 6 // year, state, state trend
ivreghdfe growth_pc  (log_provisions_`x' = shock_prov`x') if state_news_uncertain3 == 3, absorb(state##c.year year)  cl(state)
outreg2 using Table_7_unc, excel append label keep(log_provisions_`x') ctitle(High Unc - Prov)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +)  nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 7 // year FE, state FE
ivreghdfe growth_pc (log_cond_list_prov_`x' log_non_cond_list_prov_`x' = shock_cond_list_prov`x' shock_non_cond_list_prov`x') if state_news_uncertain3 == 3, absorb(state year) cl(state)
outreg2 using Table_7_unc, excel append label  ctitle(High Unc - Cont Non-cont)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 8 // year, state, state trend
ivreghdfe growth_pc (log_cond_list_prov_`x' log_non_cond_list_prov_`x' = shock_cond_list_prov`x' shock_non_cond_list_prov`x') if state_news_uncertain3 == 3, absorb(state##c.year year)  cl(state)
outreg2 using Table_7_unc, excel append label ctitle(High Unc - Cont Non-cont)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 9 // year FE, state FE
ivreghdfe growth_pc (logX_diffcond_list_prov_`x' = shock_cond_list_prov`x' shock_non_cond_list_prov`x') if state_news_uncertain3 == 3, absorb(state year) cl(state)
outreg2 using Table_7_unc, excel append label  ctitle(High Unc - Diff)  nocons addtext(State FE, X, Time FE, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)

* 10 // year, state, state trend
ivreghdfe growth_pc (logX_diffcond_list_prov_`x' = shock_cond_list_prov`x' shock_non_cond_list_prov`x')  if state_news_uncertain3 == 3, absorb(state##c.year year)  cl(state)
outreg2 using Table_7_unc, excel append label ctitle(High Unc - Diff)  nocons addtext(State FE, X, Time FE, X, State-Specific Trends, X) addstat(First Stage F-stat, e(rkf), R-squared,  e(r2)) alpha(0.01, 0.05, 0.1) symbol(**, *, +) nor2 nonotes addnote(SE clustered by `e(clustvar)', **p<.01; *p<.05; +p<.1)


